package com.yc.yuehui.mapper;

import com.yc.yuehui.entity.YhPhotoRace;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yc.yuehui.entity.YhPhotoShow;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lyl
 * @since 2023-03-07
 */
public interface YhPhotoRaceMapper extends BaseMapper<YhPhotoRace> {

    @Select("select * from yh_photo_race order by intime desc limit #{start}, #{size}")
    @Results(
            value = {
                    @Result(column = "id", property = "id", id = true),
                    @Result(column = "logo_big", property = "logoBig", id = true),
                    @Result(column = "logo_small", property = "logoSmall", id = true),
                    @Result(column = "id", property = "shows", many = @Many(
                            select = "selectByPsid"
                    ))
            }
    )
    List<YhPhotoRace> selectPage(@Param("start") int start, @Param("size") int size);

    @Select("select count(*) from yh_photo_race")
    long countPage();

    @Select("select * from yh_photo_show where psid=#{psid} order by intime desc limit 0,4")
    List<YhPhotoShow> selectByPsid(int psid);
}


